package com.wonders.controller;
import com.wonders.dto.Result;
import com.wonders.service.IVoucherOrderService;
import com.wonders.service.impl.TestRedisIdUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

/**
 * 功能描述:优惠券-订单信息服务控制层
 * @Author: yyalin
 * @CreateDate: 2023/8/13 10:56
 */
@Api(tags="优惠券-订单信息控制层")
@RestController
@RequestMapping("/voucher-order")
@Slf4j
public class VoucherOrderController {

    @Resource
    private IVoucherOrderService voucherOrderService;
    @Autowired
    private TestRedisIdUtils testRedisIdUtils;

    @ApiOperation(value="根据优惠券ID秒杀下单", notes="seckillVoucher")
    @PostMapping("seckill/{id}")
    public Result seckillVoucher(@PathVariable("id") Long voucherId) {
        return voucherOrderService.seckillVoucher(voucherId);
    }
    @ApiOperation(value="测试生成全局唯一DI耗时", notes="testRedisIdUtils")
    @PostMapping("testRedisIdUtils")
    public void testRedisIdUtils(int nums){
        try {
            testRedisIdUtils.testIdWorker(nums);
        } catch (InterruptedException e) {
            log.error("测试异常e:"+e);
        }
    }

}
